﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text.Length != 15 || TextBox1.Text.Length != 18)
            Label3.Text = "不合法";
        if (TextBox1.Text.Length == 15)
        {
            if ((TextBox1.Text.Substring(14, 1) == "1" && DropDownList1.SelectedValue == "男") || (TextBox1.Text.Substring(14, 1) == "2" && DropDownList1.SelectedValue == "女"))
            {
                Label3.Text = "合法";
            }
            else
            {
                Label3.Text = "不合法";
            }
        }
        if (TextBox1.Text.Length == 18)
        {
            if ((TextBox1.Text.Substring(16, 1) == "1" && DropDownList1.SelectedValue == "男") || (TextBox1.Text.Substring(16, 1) == "2" && DropDownList1.SelectedValue == "女") || (TextBox1.Text.Substring(16, 1) == "4" && DropDownList1.SelectedValue == "女"))
            {
                Label3.Text = "合法";
            }
            else
            {
                Label3.Text = "不合法";
            }
        }
    }
}
